//
//@File    :	8.14_temptempover.cpp
//@Time    :	2021/08/22 11:06:09
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	template overloading
//

//函数选择出问题了,第二个应该选B但是选了A

#include <iostream>

using namespace std;

template <typename T>
void ShowArray(T arr[], int n);

template <typename T>
void AhowArray(T * arr[], int n);

struct debts
{
    char name[50];
    double amount;
};

int main()
{
    int things[6] = {13, 31, 103, 301, 310, 130};
    struct debts mr_E[3] =
        {
            {"Ima Wolfe", 2400.0},
            {"Ura Foxe", 1300.0},
            {"Iby Stout", 1800.0}
        };
    double *pd[3];

    for (int i = 0; i < 3; i++)
    {
        pd[i] = &mr_E[i].amount;
    }

    cout << "Listing Mr.E's counts of things:\n";
    ShowArray(things, 6);//会使用A函数
    cout << "Listing Mr.E's debts:\n";
    ShowArray(pd, 3);//会优先使用B函数
    //选A函数时显示地址
    //选B函数时显示结构成员
    system("pause");
    return 0;
}
template <typename T>
void ShowArray(T arr[], int n)
{
    cout << "template A\n";
    for (int i = 0; i < n; i++)
    {
        cout << arr[i] << ' ';
    }
    cout << endl;
}

template <typename T>
void AhowArray(T * arr[], int n)
{
    cout << "*template B\n";
    for (int i = 0; i < n; i++)
    {
        cout << * arr[i] << ' ';
    }
    cout << endl;
}